package com.ruyuan.eshop.common.monitor;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruyuan.eshop.common.mapper.GoodsSnapshotMapper;
import com.ruyuan.eshop.common.domain.entity.GoodsSnapshotDO;
import com.ruyuan.eshop.framework.core.JsonMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *
 * </p>
 *
 * @author pwd
 * @version 1.0
 */
@RestController
@RequestMapping("/monitor")
public class MonitorController {

    @Autowired
    private GoodsSnapshotMapper goodsSnapshotMapper;

    @GetMapping("/f5")
    public JsonMap<String, Object> f5() {
        // 主要测试能不能正常访问数据库
        QueryWrapper<GoodsSnapshotDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.last("limit 1");
        GoodsSnapshotDO goodsSnapshotDO = goodsSnapshotMapper.selectOne(queryWrapper);
        JsonMap<String, Object> jsonMap = new JsonMap<>();
        if(goodsSnapshotDO != null) {
            jsonMap.put("result", true);
        } else {
            jsonMap.put("result", false);
        }
        return jsonMap;
    }

}